package com.jiepu.exercise.advanceed.chapter6;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description: IO输入 输出流 实现文件的复制
 * 文件输入流  文件输出流
 * @author: xinjie
 * @date: 2020/8/7  8:07
 */
public class CopyDemo1 {
	public static void main(String[] args) throws IOException {
		// 创建文件输入流 读取文件
		String path = "src/com/jiepu/exercise/advanceed/chapter6/poem.txt";
		FileInputStream fileInputStream = new FileInputStream(path);
		// 用来拼接和保存 已读取到的文件数据
		// text 浪费空间 生成大量字符串
		List<byte[]> list = new ArrayList<>();

		byte[] buf = new byte[128];
		int len = -1;
		while ((len = fileInputStream.read(buf)) != -1) {
			String str = new String(buf, 0, len);
			list.add(buf);
			buf = new byte[128];
		}

		String targetpath = "src/com/jiepu/exercise/advanceed/chapter6/poemcopy.txt";
		FileOutputStream fileOutputStream = new FileOutputStream(targetpath);
		for (byte[] b : list) {


		}
	} // main

}
